package com.wjq.service;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.wjq.entity.ChoiceQuestion;
import com.wjq.entity.EssayQuestion;
import com.wjq.mapper.ChoiceQuestionMapper;
import com.wjq.mapper.EssayQuestionMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class EssayQuestionServiceImpl implements EssayQuestionService{

    @Autowired
    EssayQuestionMapper essayQuestionMapper;

    @Override
    public List<EssayQuestion> getQuestions(Integer id){
        List<EssayQuestion> essayQuestions = essayQuestionMapper.queryList(id);
        return essayQuestions;
    }

    @Override
    public void updateQuestion(EssayQuestion essayquestion){
//        String s ="{\"id\":\"2\",\"description\":\"下面哪句话出自《孟子》？\"," +
//                "\"questionnaire_id\":\"1\",\"serial_num\":\"5\", \"multi_select\":\"0\"}";
//        String s2 ="{\"id\":\"2\",\"description\":\"写首自我最最喜爱的歌？\"," +
//                "\"questionnaire_id\":\"1\",\"serial_num\":\"5\"}";

        System.out.println(essayquestion.getId() + " " + essayquestion.getDescription() + " " + essayquestion.getQuestionnaireId() + " "+
                essayquestion.getSerialNum());
        essayQuestionMapper.updateEssayQuestionById(essayquestion);

    }

    @Override
    public void addQuestion(EssayQuestion essayQuestion){
        essayQuestionMapper.addEssayQuestion(essayQuestion);
    }


    @Override
    public void deleteQuestion(Integer id) {
        essayQuestionMapper.deleteEssayQuestionById(id);
    }

    @Override
    public EssayQuestion selectEssayQuestion(Integer id) {
        return essayQuestionMapper.selectEssayQuestionById(id);
    }
}
